<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
	<style>
		#InfoHit{color:#00F;font-weight:normal;}
		#NoData{color:#F00;	text-align:left;padding-left:10px;}
		#selecttip, #cidtip{ color:red;}
	</style>
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
            	<form enctype="multipart/form-data"  method="post" id="frmInfo">
                <input type="hidden" name="ChannelID" id="ChannelID" value="{$ChannelID}" />
                <input type="hidden" name="NowPage" id="NowPage" value="{$NowPage}" />
                <input type="hidden" name="ChannelModelID" id="ChannelModelID" value="{$ChannelModelID}" />
<div id="dialog" title="批量移动" style="display:none">
<table>
    <tr>
       <th width="80px" nowrap="nowrap" align="right"><span style="font-weight:bold;color:blue;padding-right:3px;">所属频道</span></th>
       <th align="left"><channelselect selectvalue="$ChannelID" menuowner="0" groupid="$GroupID" name="cid" id="cid"  hasSingleChannel="1" /></th>
    </tr>
    <tr>
        <td nowrap="nowrap" align="right"><span style="font-weight:bold;color:blue;padding-right:3px;">专题</span></th>
        <td align="left"  style="padding-top:5px;"><specialselect size="8" style='width:300px' name="sid[]" id="sid"/></td>
    </tr>
     <tr><th align="right" colspan="2"><div id="cidtip"></div></th></tr>
</table>
</div>

<div id="dlgAttr" title="批量设置属性" style="display:none">
<table>
    <tr>
    <th width="80px" nowrap="nowrap" style="text-align:right;font-weight:bold;color:blue;padding-right:5px">属性标记</th>
    <th align="left"><labelcheckbox channelmodelid="30" name="lid[]" id="lid" separator="&nbsp;&nbsp;"/></th>
    </tr>
    <tr>
        <td nowrap="nowrap" style="text-align:right;font-weight:bold;color:blue;padding-right:5px">是否启用</th>
        <td align="left">
            <label><input type="radio" name="IsEnable" value="1" checked="checked"/>启用</label>
            &nbsp;&nbsp;
            <label><input type="radio" name="IsEnable" value="0" />不启用</label>
        </th>
    </tr>
</table>
</div>

<div id="dlgSelect" title="请选择频道" style="display:none">
<table>
    <tr>
       <th width="80px" nowrap="nowrap" align="right"><span style="font-weight:bold;color:blue;padding-right:3px;">所属频道</span></th>
       <th align="left">
       		<channelselect selectvalue="$ChannelID" menuowner="0" groupid="$GroupID" name="selectcid" id="selectcid"  hasSingleChannel="1" />
       </th>
    </tr>
    <tr><th align="right" colspan="2"><div id="selecttip"></div></th></tr>
</table>
</div>
                  <div class="table">
                    <div class="toolbars">
                        <li class="toolbar"><a id="btnAdd" onclick="Add()"  title="我要发布文章" target="_self">我要发布文章</a></li>
                        <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
                        <li class="toolbar"><a id="del" onclick="BatchDel()" title="批量删除">删除</a></li>
                        <li class="toolbar"><a id="move" title="批量移动">移动</a></li>
                        <li class="toolbar"><a id="attr" title="属性批量设置">属性</a></li>
                        <li class="toolbar toolbarform">
                        	<channelselect selectvalue="$ChannelID" menuowner="0" groupid="$GroupID" name="searchcid" id="searchcid"  hasSingleChannel="1" firstvalue="0" firsttext="所有频道" />
                            <input id="btnSeek" class="btnToolbarForm" type="submit" value="查询" onclick="Search()">
                        </li>
                  </div>
                    <table class="datatable" id="datatable">
                    <tr>
                        <th width="35px"  nowrap="nowrap">选中</th>
                        <th width="50px" nowrap="nowrap">ID</th>
                        <th width="50px" nowrap="nowrap">排序</th>
                        <th>标题</th>
                        <th width="160px" nowrap="nowrap">所属频道</th>
                        
                        <th width="65px" nowrap="nowrap">点击次数</th>
                        <th width="85px" >属性</th>
                        <th width="130px" nowrap="nowrap">发布时间</th>
                        <th style="width:150px;">操作</th>
                    </tr>  
    <notempty name="Info">                
    <volist name="Info" id="f">
    <tr>
    	<td><input class="checkrow" type="checkbox" name="InfoID[]" value="{$f.InfoID}" /></td>
        <td>{$f.InfoID}</td>
        <td><input type="text" class='textinput' onclick="this.select()" style="width:50px" name="InfoOrder[]" value="{$f.InfoOrder}" />
        <input type="hidden" class='textinput' style="width:50px" name="InfoOrderID[]" value="{$f.InfoID}" /></td>
        <td style="text-align:left">
        <if condition="$f['IsCheck'] == 1 AND $f['IsEnable'] == 1">
        	<a href="{$f.InfoUrl}" title="{$f.InfoTitle}" target="_blank">{$f.InfoTitle|Left=35}</a>
        <else/>
        	{$f.InfoTitle|Left=35}
        </if>
        <notempty name="i.InfoPicture">&nbsp;&nbsp;<b class="TagTip" alt="{$f.InfoPicture}" style="color:#F00">[图]</b></notempty>
        </td>
        <td><a href="{$f.ChannelUrl}" target="_blank">{$f.ChannelName}</a></td>
        <td id="InfoHit">{$f.InfoHit}</td>
        <td>
        <eq name="f.IsCheck" value="1">
        	<span style="color:#000">已审核</span><else/><span style="color:#F00">未审核</span>
        </eq>
        &nbsp;
        <eq name="f.IsEnable" value="1">
        	<span style="color:#000">启用</span><else/><span style="color:#F00">禁用</span>
        </eq>
        </td>
        <td>{$f.InfoTime|strtotime|yd_friend_date}</td>
        <td class="operator">
            <a style="float:left" onclick="Edit({$f.InfoID},{$f.ChannelID})" id="btnEdit">修改</a>
            <div class="btn-sep"></div>
            <a style="float:left" onclick="Del({$f.InfoID},{$f.ChannelID})" class="btnDel">删除</a>
        </td>
    </tr>
    </volist>
    <else/>
    	<tr><td colspan="9" id="NoData">{$Think.lang.NoDataTip}</td></tr>
    </notempty>                                
    </table>
         <div class="tfoot"><div class="page">{$Page}</div></div>
   </div>
</form>
</div>
</body>
</html>
<script type="text/javascript">
//批量删除
function BatchDel(){
	var arrChk = $("input[name='InfoID[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		var showall = "{$ChannelID}";
		showall = (showall==0) ? 1 : 0; //是否显示所有频道
		$('#frmInfo').attr("action", "__URL__/batchDel/showall/"+showall);
		$('#frmInfo').submit();
	}, function () {
		return true;
	});
}

//排序
function BatchSort(){
	$.confirm("{$Think.lang.SortTip}", function () {
		$('#frmInfo').attr("action", "__URL__/batchSort");
		$('#frmInfo').submit();
	}, function () {
		return true;
	});
}

$(document).ready(function(){
	$(".TagTip").powerFloat({
			targetMode: "ajax",
			targetAttr: "alt"
	});
		
	$('#attr').click(function(){
		var arrChk = $("input[name='InfoID[]']");
		var n = 0;
		for(var i = 0; i < arrChk.length; i++){
			if(arrChk[i].checked) n++;
		}
		
		if( n == 0 ) {
			WarnBox("请先选中记录!");
			return;
		}
		
		$.dialog({
			title: "批量设置属性",
			id: 'dlgAttr',
			padding: 5,
			content: document.getElementById('dlgAttr'),
			ok: function () {
				$("#dlgAttr").appendTo("form#frmInfo");
				$('#frmInfo').attr("action", "__URL__/batchLabel");
				$('#frmInfo').submit();
			},
			okValue: '确定',
			cancelValue: '关闭',
			cancel: true
		});
		return false;
	});
	
	$('#move').click(function(){
		var arrChk = $("input[name='InfoID[]']");
		var n = 0;
		for(var i = 0; i < arrChk.length; i++){
			if(arrChk[i].checked) n++;
		}
		
		if( n == 0 ) {
			WarnBox("请先选中记录!");
			return;
		}
		
		$.dialog({
			title: "批量移动",
			id: 'dialog',
			padding: 5,
			content: document.getElementById('dialog'),
			ok: function () {
				var hasChild = $("#cid").children("option:selected").attr("hasChild");
				if(hasChild==1){
					$("#cidtip").text("只能移动到子频道！");
					return false;
				}
				var cmid = $("#cid").children("option:selected").attr("cmid");
				if(cmid==32){
					$("#cidtip").text("不能移动到单页频道！");
					return false;
				}
				if(cmid==33){
					$("#cidtip").text("不能移动到链接频道！");
					return false;
				}
				$("#dialog").appendTo("form#frmInfo");
				$('#frmInfo').attr("action", "__URL__/batchMove");
				$('#frmInfo').submit();
			},
			okValue: '确定',
			cancelValue: '关闭',
			cancel: true
		});
		return false;
	});
});

function Add(){
	var showall = "{$ChannelID}";
	showall = (showall==0) ? 1 : 0; //是否显示所有频道
	$.dialog({
		title: "请选择频道",
		id: 'dlgSelect',
		padding: 5,
		content: document.getElementById('dlgSelect'),
		ok: function () {
			var hasChild = $("#selectcid").children("option:selected").attr("hasChild");
			if(hasChild==1){
				$("#selecttip").text("请选择子频道发布文章！");
				return false;
			}
			var cmid = $("#selectcid").children("option:selected").attr("cmid");
			if(cmid==32){
				$("#selecttip").text("不能在单页频道发布文章！");
				return false;
			}
			if(cmid==33){
				$("#selecttip").text("不能在链接频道发布文章！");
				return false;
			}
			var cid = $("#selectcid").val();
			location.href = "{$Url}add/ChannelID/"+cid+"/showall/"+showall;
		},
		okValue: '确定',
		cancelValue: '关闭',
		cancel: true
	});
}

function Del(id, ChannelID){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		var showall = "{$ChannelID}";
		showall = (showall==0) ? 1 : 0; //是否显示所有频道
		url = "{$Url}del/InfoID/"+id+"/ChannelID/"+ChannelID+"/p/{$NowPage}/showall/"+showall;;
		location.href = url;
	}, function () {
		return true;
	});
}

function Edit(id, ChannelID){
	var showall = "{$ChannelID}";
	showall = (showall==0) ? 1 : 0; //是否显示所有频道
	var url = "{$Url}modify/InfoID/"+id+"/ChannelID/"+ChannelID+"/showall/"+showall;
	location.href = url;
}

//查询
function Search(){
	var cid = $("#searchcid").val();
	var action = (cid==0) ? "{$Url}index" : "{$Url}index/ChannelID/"+cid;
	$('#frmInfo').attr("action", action);
	$('#frmInfo').submit();
	return true;
}
</script>